home *** CD-ROM | disk | FTP | other *** search
- /*
- File: LnkDlgEx.cpp
-
- Contains: implementation of the Paste As and Link Info dialogs
-
- Owned by: Craig Carper
-
- Copyright: © 1993 - 1996 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <4> 7/8/96 eeh undo task 10008 (AppleGuide buttons)
- <3> 6/21/96 eeh task 10008: add buttons etc. for AppleGuide
- <2> 6/21/96 RA T10025: Call InitBndNSUtils
- <1> 6/7/96 eeh first checked in (based on LinkDlgs.cpp)
-
- In Progress:
-
- */
-
- #ifndef _PLFMDEF_
- #include <plfmdef.h>
- #endif
-
- #ifndef _LINKDLGS_
- #include <LinkDlgs.h>
- #endif
-
- #ifndef _INFOUTIL_
- #include <InfoUtil.h>
- #endif
-
- #ifndef _DLOGUTIL_
- #include <DlogUtil.h>
- #endif
-
- #ifndef _EXCEPT_
- #include <Except.h>
- #endif
-
- #ifndef _LINKDEFS_
- #include <LinkDefs.h>
- #endif
-
- #ifndef _USERSRCM_
- #include <UseRsrcM.h>
- #endif
-
- #ifndef _AGSUPPORT_
- #include "AGSupprt.h"
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdProps_defined
- #include <StdProps.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_Foci_defined
- #include <Foci.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdTypes_defined
- #include <StdTypes.xh>
- #endif
-
- #ifndef SOM_ODTypeList_xh
- #include <TypeList.xh>
- #endif
-
- #ifndef SOM_ODTypeListIterator_xh
- #include <TypLsItr.xh>
- #endif
-
- #ifndef SOM_ODStorageUnit_xh
- #include <StorageU.xh>
- #endif
-
- #ifndef SOM_ODPart_xh
- #include <Part.xh>
- #endif
-
- #ifndef SOM_ODFrame_xh
- #include <Frame.xh>
- #endif
-
- #ifndef SOM_ODFacet_xh
- #include <Facet.xh>
- #endif
-
- #ifndef SOM_ODBaseLink_xh
- #include <LinkB.xh>
- #endif
-
- #ifndef SOM_ODBaseLinkSource_xh
- #include <LinkSrcB.xh>
- #endif
-
- #ifndef SOM_ODBinding_xh
- #include <ODBindng.xh>
- #endif
-
- #ifndef SOM_ODTranslation_xh
- #include <Translt.xh>
- #endif
-
- #ifndef SOM_ODWindowState_xh
- #include <WinStat.xh>
- #endif
-
- #ifndef _BINDNGH_
- #include <BindngH.h>
- #endif
-
- #ifndef _BNDNSUTL_
- #include <BndNSUtl.h>
- #endif
-
- #ifndef SOM_ODSession_xh
- #include <ODSessn.xh>
- #endif
-
- #ifndef SOM_ODArbitrator_xh
- #include <Arbitrat.xh>
- #endif
-
- #ifndef SOM_ODDispatcher_xh
- #include <Disptch.xh>
- #endif
-
- #ifndef _ODUTILS_
- #include <ODUtils.h>
- #endif
-
- #ifndef _PASCLSTR_
- #include <PasclStr.h>
- #endif
-
- #ifndef _ISOSTR_
- #include <ISOStr.h>
- #endif
-
- #ifndef _DOCUTILS_
- #include <DocUtils.h>
- #endif
-
- #ifndef _ODMEMORY_
- #include <ODMemory.h>
- #endif
-
- #ifdef __SC__
- #ifndef __PACKAGES__
- #include <Packages.h>
- #endif
- #else
- #ifndef __TEXTUTILS__
- #include <TextUtils.h>
- #endif
- #endif
-
- #ifndef __STRING__
- #include <String.h>
- #endif
-
- #ifndef __GESTALTEQU__
- #include <GestaltEqu.h>
- #endif
-
- #ifndef __DIALOGS__
- #include <Dialogs.h>
- #endif
-
- #ifndef __TOOLUTILS__
- #include <ToolUtils.h>
- #endif
-
- #ifndef __FONTS__
- #include <Fonts.h>
- #endif
-
- #ifndef __CONTROLS__
- #include <Controls.h>
- #endif
-
- #ifndef __RESOURCES__
- #include <Resources.h>
- #endif
-
- #ifndef _TRANSUTL_
- #include <TransUtl.h>
- #endif
-
- #ifndef __LISTS__
- #include <Lists.h>
- #endif
-
- #ifndef __PALETTES__
- #include <Palettes.h>
- #endif
-
- #ifndef _STORUTIL_
- #include <StorUtil.h>
- #endif
-
- #ifndef _EDITRSET_
- #include <EditrSet.h>
- #endif
-
- #ifndef _STDTYPIO_
- #include <StdTypIO.h>
- #endif
-
- #ifndef _TEMPOBJ_
- #include <TempObj.h>
- #endif
-
- #ifndef _ORDCOLL_
- #include "OrdColl.h"
- #endif
-
- #ifndef SOM_ODStorageSystem_xh
- #include "ODStor.xh"
- #endif
-
- #pragma segment Info
-
- #if ODDebug
- #define ODDebugLinkDlgs 0
- #else
- #define ODDebugLinkDlgs 0
- #endif
-
- //==============================================================================
- // Global variables
- //==============================================================================
-
- // Use a global to pass the current session to the LinkFilterProc
- // Globals are per process, and there is only one session per process.
- //static ODSession* gSession = kODNULL;
-
- static ODName* gKindName = kODNULL;
- static ODName* gEditorName = kODNULL;
- static ODName* gEmbeddedEditorName = kODNULL;
-
- //==============================================================================
- // Constants
- //==============================================================================
-
- const Boolean kNoDefaultButton = kODFalse;
-
- const short kButtonFrameInset = -4;
-
- const short kControlInactive = 255;
- const short kControlActive = 0;
-
- // Constants used in list manager calls
- const Boolean kDoDraw = true;
- const Boolean kNoGrow = false;
- const Boolean kIncludeScrollBar = true;
-
- // Key codes
- // <eeh> moved to DlogUtil.h
- // const char kEnterKey = 0x03;
- // const char kReturnKey = 0x0D;
- // const char kEscapeKey = 0x1B;
- // const char kUpArrowKey = 0x1E;
- // const char kDownArrowKey = 0x1F;
-
- //==============================================================================
- // Scalar types
- //==============================================================================
- typedef char ODHandleState;
-
- //==============================================================================
- // Function declarations
- //==============================================================================
- ODStatic void DisposeGlobalODNameAndZeroPtr(ODName** name);
-
- ODStatic void SetDateTimeStrings(
- ODULong dateTime,
- Str255 dateString,
- Str255 timeString);
-
- ODStatic void InitItemActive(
- DialogPtr dlg,
- short itemNumber,
- UserItemUPP itemUPP,
- ODBoolean itemActive);
-
- ODStatic pascal void DrawDeactivePICTItem(DialogPtr theDialog, short theItem);
-
- ODStatic ODBoolean DraftIsReadOnly(Environment* ev, ODStorageUnit* su);
-
- ODStatic void SetControlActive(
- DialogPtr dlg,
- short itemNumber,
- ODBoolean itemActive);
-
- ODStatic ODType BestContentKind(ODStorageUnit* contentSU);
-
- ODStatic pascal void DrawKindName(DialogPtr dialog, SInt16 item);
- ODStatic pascal void DrawEditorName(DialogPtr dialog, SInt16 item);
-
- ODStatic void ResetEditorPopup(ODTypeList* kindList,
- ODUShort kindIndex,
- ODTypeList* translateToList,
- ODUShort translateToIndex,
- EditorSet* editorList,
- MenuHandle editorMenu,
- ControlHandle popupCtlHndl,
- ODSession* session);
-
- static pascal Boolean
- PasteAsFilterProc(DialogPtr dialog, EventRecord *event, short *itemHit);
-
- ODStatic void SetPopupControlValue(ControlHandle popupControlHandle, short itemValue);
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- ODError ShowPasteAsDialogEx(
- ODBoolean canPasteLink,
- ODPasteAsMergeSetting mergeSetting,
- ODBoolean isMove,
- ODStorageUnit* contentSU,
- ODFacet* facet,
- ODTypeToken viewType,
- ODPasteAsResult* result,
- ODBoolean* boolResult);
-
- ODError ShowLinkSourceInfoEx(
- ODBaseLinkSource* linkSource,
- ODUpdateID change,
- ODBoolean changesAllowed,
- ODLinkInfoResult* infoResult,
- ODBoolean* boolResult);
-
- ODError ShowLinkDestinationInfoEx(
- ODBaseLink* link,
- ODLinkInfo* info,
- ODBoolean changesAllowed,
- ODLinkInfoResult* infoResult,
- ODBoolean* boolResult);
-
- #ifdef __cplusplus
- }
- #endif
-
- //------------------------------------------------------------------------------
- // DisposeGlobalODNameAndZeroPtr
- //------------------------------------------------------------------------------
- ODStatic void DisposeGlobalODNameAndZeroPtr(ODName** name)
- {
- if (*name)
- {
- // simple way to force deletion of old name value without knowing
- // that DisposeIText is the right way to destroy an ODName:
- TempODName tempName = *name;
- *name = kODNULL;
- }
- }
-
- //------------------------------------------------------------------------------
- // DrawEditorName
- //------------------------------------------------------------------------------
-
- ODStatic pascal void DrawEditorName(DialogPtr dialog, SInt16 item)
- {
- short itemType;
- Handle itemHandle;
- Rect itemRect;
-
- GetDialogItem(dialog, item, &itemType, &itemHandle, &itemRect);
-
- if ( gEditorName )
- DrawITextInDlogBox(gEditorName, &itemRect, dialog, kODTrue);
- }
-
- //------------------------------------------------------------------------------
- // DrawEmbeddedEditorName
- //------------------------------------------------------------------------------
-
- ODStatic pascal void DrawEmbeddedEditorName(DialogPtr dialog, SInt16 item)
- {
- short itemType;
- Handle itemHandle;
- Rect itemRect;
-
- GetDialogItem(dialog, item, &itemType, &itemHandle, &itemRect);
-
- if ( gEmbeddedEditorName )
- DrawITextInDlogBox(gEmbeddedEditorName, &itemRect, dialog, kODTrue);
- }
-
- //------------------------------------------------------------------------------
- // GetSelectedType
- //------------------------------------------------------------------------------
- // $$$$$ Should be replaced by GetThisKindFromList in InfoUtil.h
-
- ODStatic ODType GetSelectedType(ODTypeList* typeList, ODSShort typeIndex)
- {
- Environment* ev = somGetGlobalEnvironment();
- ODType type = kODNULL;
- ODTypeListIterator* iter = typeList->CreateTypeListIterator(ev);
-
- for ( type = iter->First(ev);
- (--typeIndex > 0) && iter->IsNotComplete(ev);
- type = iter->Next(ev) )
- {
- ODDisposePtr(type);
- type = kODNULL;
- }
-
- delete iter;
-
- return type;
- }
-
- //------------------------------------------------------------------------------
- // GetSelectedEditor
- //------------------------------------------------------------------------------
-
- ODStatic ODEditor GetSelectedEditor(EditorSet* editorList, ODSShort editorIndex)
- {
- ODEditor editor;
- EditorSetIterator* iter = editorList->CreateIterator();
-
- for ( editor = iter->First();
- (--editorIndex > 0) && iter->IsNotComplete();
- editor = iter->Next() )
- {
- }
-
- delete iter;
-
- if ( editor != kODNULL )
- editor = ODISOStrFromCStr((char *) editor);
-
- return editor;
- }
-
- //------------------------------------------------------------------------------
- // EnableKindPopupItems
- //------------------------------------------------------------------------------
-
- ODStatic void EnableKindPopupItems(
- ODBoolean forMerge,
- ODTypeList* typeList,
- ODTypeList* translateList,
- ODSShort translationIndex,
- MenuHandle kindMenu,
- ODEditor editor,
- ODNameSpaceManager* nsm)
- {
- Environment* ev = somGetGlobalEnvironment();
-
- ODUShort item = EnableTypesInMenu(typeList, kindMenu, forMerge ? editor : kODNULL, nsm);
-
- // If a translation choice is present in the popup, enable it if appropriate;
- if ( translationIndex != 0 )
- {
- TempODType translationKind = GetSelectedType(translateList, translationIndex);
-
- if ( !forMerge || EditorSupportsKind(nsm, editor, translationKind) )
- EnableItem(kindMenu, ++item);
- else
- DisableItem(kindMenu, ++item);
- }
-
- // Enable the "Translate to…" item in the kind popup if translation is possible
- if ( translateList->Count(ev) > 0 )
- EnableItem(kindMenu, ++item);
- else
- DisableItem(kindMenu, ++item);
- }
-
- //------------------------------------------------------------------------------
- // EnablePasteAsOkButton
- //------------------------------------------------------------------------------
-
- ODStatic void EnablePasteAsOkButton(DialogPtr dlog, MenuHandle kindMenu)
- {
- Environment* ev = somGetGlobalEnvironment();
- short itemType;
- Handle itemHandle;
- Rect itemRect;
- ODSShort kindItemSelected;
- ODBoolean shouldBeEnabled;
-
- GetDialogItem(dlog, kPasteAsKindPopup, &itemType, &itemHandle, &itemRect);
- ASSERT_CONTROL_ITEM(itemType);
- kindItemSelected = (ODSShort) GetControlValue((ControlHandle)itemHandle);
-
- // Only the first 31 items of a menu may be disabled
- if ( kindItemSelected > 31 )
- shouldBeEnabled = kODTrue;
- else
- // BitTst numbers the bits hi to low
- shouldBeEnabled = BitTst(&(**kindMenu).enableFlags, 31-kindItemSelected);
-
- EnableOkButton(dlog, shouldBeEnabled);
- }
-
- //------------------------------------------------------------------------------
- // BestMergeKindSetting
- //------------------------------------------------------------------------------
-
- ODStatic ODSShort BestMergeKindSetting(
- ODTypeList* kinds,
- ODType bestKind,
- ODEditor editor,
- ODNameSpaceManager* nsm)
- {
- if ( bestKind && EditorSupportsKind(nsm, editor, bestKind) )
- return IndexOfKindInList(kinds, bestKind);
-
- Environment* ev = somGetGlobalEnvironment();
- ODSShort kindItem = 0; // Default in case none are supported
-
- ODTypeListIterator* iter = kinds->CreateTypeListIterator(ev);
-
- ODType type;
- ODSShort i;
- for ( type = iter->First(ev), i = 1;
- iter->IsNotComplete(ev);
- type = iter->Next(ev), ++i )
- {
- ODBoolean supports = EditorSupportsKind(nsm, editor, type);
- ODDisposePtr(type);
- if ( supports )
- {
- kindItem = i;
- break;
- }
- }
-
- delete iter;
-
- return kindItem;
- }
-
- //------------------------------------------------------------------------------
- // InitialViewSelection
- //------------------------------------------------------------------------------
- ODStatic void InitialViewSelection(DialogPtr dlg, ODTypeToken viewType, ODSession* session)
- {
- short itemType;
- Handle itemHandle;
- Rect itemRect;
- ODSShort viewItem;
-
- Environment* ev = somGetGlobalEnvironment();
-
- if (viewType == session->Tokenize(ev, kODViewAsFrame))
- viewItem = kODPasteAsFrameMenuItem;
- else if (viewType == session->Tokenize(ev, kODViewAsLargeIcon))
- viewItem = kODPasteAsLargeIconMenuItem;
- else if (viewType == session->Tokenize(ev, kODViewAsSmallIcon))
- viewItem = kODPasteAsSmallIconMenuItem;
- else if (viewType == session->Tokenize(ev, kODViewAsThumbnail))
- viewItem = kODPasteAsThumbnailMenuItem;
- else
- viewItem = kODPasteAsFrameMenuItem;
-
- GetDialogItem(dlg, kPasteAsEmbedPopup, &itemType, &itemHandle, &itemRect);
- ASSERT_CONTROL_ITEM(itemType);
- SetControlValue((ControlHandle)itemHandle, viewItem);
- }
-
- //------------------------------------------------------------------------------
- // GetViewSelected
- //------------------------------------------------------------------------------
- ODStatic ODTypeToken GetViewSelected(DialogPtr dlg, ODSession* session)
- {
- short itemType;
- Handle itemHandle;
- Rect itemRect;
-
- Environment* ev = somGetGlobalEnvironment();
-
- GetDialogItem(dlg, kPasteAsEmbedPopup, &itemType, &itemHandle, &itemRect);
- ASSERT_CONTROL_ITEM(itemType);
- ODSShort viewItem = (ODSShort) GetControlValue((ControlHandle)itemHandle);
- ODType viewAs;
- switch ( viewItem )
- {
- case kODPasteAsLargeIconMenuItem:
- viewAs = kODViewAsLargeIcon;
- break;
- case kODPasteAsSmallIconMenuItem:
- viewAs = kODViewAsSmallIcon;
- break;
- case kODPasteAsThumbnailMenuItem:
- viewAs = kODViewAsThumbnail;
- break;
- default:
- viewAs = kODViewAsFrame;
- break;
- }
-
- return session->Tokenize(ev, viewAs);
- }
-
- //------------------------------------------------------------------------------
- // HaveColorQuickdraw
- //------------------------------------------------------------------------------
- ODStatic ODBoolean HaveColorQuickdraw()
- {
- long response;
-
- Gestalt(gestaltQuickdrawFeatures, &response);
-
- /* check if Color QuickDraw is available */
- return BitTst(&response, 31-gestaltHasColor);
- }
-
- //------------------------------------------------------------------------------
- // EnableDialogItem
- //------------------------------------------------------------------------------
- ODStatic void EnableDialogItem(DialogPtr dlg, short itemNumber, ODBoolean enable)
- {
- short itemType;
- Handle itemHandle;
- Rect itemRect;
-
- GetDialogItem(dlg, itemNumber, &itemType, &itemHandle, &itemRect);
- if ( enable )
- itemType &= ~itemDisable;
- else
- itemType |= itemDisable;
- SetDialogItem(dlg, itemNumber, itemType, itemHandle, &itemRect);
- }
-
- //------------------------------------------------------------------------------
- // InvalDialogItem
- //------------------------------------------------------------------------------
- ODStatic void InvalDialogItem(DialogPtr dlg, short itemNumber)
- {
- short itemType;
- Handle itemHandle;
- Rect itemRect;
- WindowPtr savePort;
-
- GetPort(&savePort);
- SetPort(dlg);
- GetDialogItem(dlg, itemNumber, &itemType, &itemHandle, &itemRect);
- InvalRect(&itemRect);
- SetPort(savePort);
- }
-
- //------------------------------------------------------------------------------
- // SetPopupControlValue
- //------------------------------------------------------------------------------
- ODStatic void SetPopupControlValue(ControlHandle popupControlHandle, short itemValue)
- {
- // The resource file must be in the chain in order for the popup to redraw.
- CUsingLibraryResources r;
- SetControlValue(popupControlHandle, itemValue);
- }
-
- //------------------------------------------------------------------------------
- // SetupControlItem
- //------------------------------------------------------------------------------
- ODStatic void SetupControlItem(
- DialogPtr dlg,
- short itemNumber,
- short itemValue,
- ODBoolean itemActive)
- {
- short itemType;
- Handle itemHandle;
- Rect itemRect;
-
- GetDialogItem(dlg, itemNumber, &itemType, &itemHandle, &itemRect);
- ASSERT_CONTROL_ITEM(itemType);
- SetControlValue((ControlHandle)itemHandle, itemActive? itemValue : 0);
- HiliteControl((ControlHandle)itemHandle, itemActive ? kControlActive : kControlInactive);
- }
-
- //------------------------------------------------------------------------------
- // InactivateEmbedAsPopup
- //------------------------------------------------------------------------------
-
- ODStatic void InactivateEmbedAsPopup(DialogPtr dlg)
- // Set clipping to just the display area of the popup so the radio button
- // label isn't dimmed.
- {
- short aItem;
- Handle aHandle;
- Handle embedPopupCntlHandle;
- Rect aRect;
- RgnHandle embedTextRgn = ODNewRgn();
- RgnHandle embedPopupRgn = ODNewRgn();
- RgnHandle clipRgn = ODNewRgn();
-
- GetDialogItem(dlg, kPasteAsEmbedRadioBtn, &aItem, &aHandle, &aRect);
- RectRgn(embedTextRgn,&aRect);
-
- GetDialogItem(dlg, kPasteAsEmbedPopup, &aItem, &embedPopupCntlHandle, &aRect);
- RectRgn(embedPopupRgn,&aRect);
-
- GetClip(clipRgn);
- DiffRgn(embedPopupRgn, embedTextRgn, embedPopupRgn);
- SetClip(embedPopupRgn);
- HiliteControl((ControlHandle)embedPopupCntlHandle, kControlInactive);
- SetClip(clipRgn);
-
- ODDisposeHandle((Handle)clipRgn);
- ODDisposeHandle((Handle)embedPopupRgn);
- ODDisposeHandle((Handle)embedTextRgn);
- }
-
- //------------------------------------------------------------------------------
- // ClipOutRect
- //------------------------------------------------------------------------------
-
- ODStatic RgnHandle ClipOutRect(Rect* r)
- {
- RgnHandle saveRgn = ODNewRgn();
- RgnHandle rectRgn = ODNewRgn();
- RgnHandle clipRgn = ODNewRgn();
-
- GetClip(saveRgn);
-
- RectRgn(rectRgn, r);
-
- GetClip(clipRgn);
- DiffRgn(clipRgn, rectRgn, clipRgn);
- SetClip(clipRgn);
-
- ODDisposeHandle((Handle)rectRgn);
- ODDisposeHandle((Handle)clipRgn);
-
- return saveRgn;
- }
-
- //------------------------------------------------------------------------------
- // SetAutomaticUpdateControls
- //------------------------------------------------------------------------------
- ODStatic void SetAutomaticUpdateControls(DialogPtr dlg, ODBoolean autoUpdateSetting)
- {
- short itemType;
- Handle itemHandle;
- Rect itemRect;
-
- GetDialogItem(dlg, kPasteAsAutomaticRadioBtn, &itemType, &itemHandle, &itemRect);
- ASSERT_CONTROL_ITEM(itemType);
- SetControlValue((ControlHandle)itemHandle, autoUpdateSetting);
- GetDialogItem(dlg, kPasteAsManualRadioBtn, &itemType, &itemHandle, &itemRect);
- ASSERT_CONTROL_ITEM(itemType);
- SetControlValue((ControlHandle)itemHandle, !autoUpdateSetting);
- }
-
- //------------------------------------------------------------------------------
- // SetMergeEmbedControls
- //------------------------------------------------------------------------------
- ODStatic void SetMergeEmbedControls(DialogPtr dlg, ODBoolean mergeSetting)
- {
- short itemType;
- Handle itemHandle;
- Rect itemRect;
-
- CUsingLibraryResources r; // Necessary to change embed popup
-
- GetDialogItem(dlg, kPasteAsMergeRadioBtn, &itemType, &itemHandle, &itemRect);
- ASSERT_CONTROL_ITEM(itemType);
- SetControlValue((ControlHandle)itemHandle, mergeSetting);
-
- GetDialogItem(dlg, kPasteAsEmbedRadioBtn, &itemType, &itemHandle, &itemRect);
- ASSERT_CONTROL_ITEM(itemType);
- SetControlValue((ControlHandle)itemHandle, !mergeSetting);
-
- if ( mergeSetting )
- {
- InactivateEmbedAsPopup(dlg);
- }
- else
- {
- GetDialogItem(dlg, kPasteAsEmbedPopup, &itemType, &itemHandle, &itemRect);
- ASSERT_CONTROL_ITEM(itemType);
- HiliteControl((ControlHandle)itemHandle, kControlActive);
- }
- }
-
- //------------------------------------------------------------------------------
- // GetIndexedElement
- //------------------------------------------------------------------------------
-
- ODStatic ODULong GetIndexedElement(OrderedCollection* translateFromList, ODULong translationIndex)
- {
- OrderedCollectionIterator* oci = translateFromList->CreateIterator();
-
- ODULong elem = 0;
-
- for ( elem = (ODULong) oci->First();
- oci->IsNotComplete();
- elem = (ODULong) oci->Next() )
- {
- if ( --translationIndex == 0 )
- break;
- }
-
- ODDeleteObject(oci);
-
- return elem;
- }
-
- //------------------------------------------------------------------------------
- // GetOriginalDraft
- //------------------------------------------------------------------------------
- // Returns 0 if the original draft is unknown. This is the case when content
- // was placed in the draft without cloning. This code is dependent on properties
- // created by the argument storage unit's container suite.
-
-
- static ODULong GetOriginalDraft(Environment* ev, ODDraft* draft)
- {
- TempODStorageUnit draftProperties = draft->AcquireDraftProperties(ev);
- return ODGetULongProp(ev, draftProperties, kODPropOriginalDraft, kODULong);
- }
-
- //------------------------------------------------------------------------------
- // SUClonedFromDraft
- //------------------------------------------------------------------------------
- // Returns kODTrue is the argument storage unit is the clone of a storage unit
- // from the argument draft. This code is dependent on properties created by
- // the argument storage unit's container suite.
-
- static ODBoolean SUClonedFromDraft(Environment* ev,
- ODStorageUnit* su,
- ODDraft* draft)
- {
- return ((ODDraft*)GetOriginalDraft(ev, su->GetDraft(ev)) == draft &&
- su->Exists(ev, kODPropOriginalID, kODULong, 0));
- }
-
- //------------------------------------------------------------------------------
- // DeactivateModalDialog
- //------------------------------------------------------------------------------
-
- ODStatic void DeactivateModalDialog(ModalFilterUPP filterProc)
- {
- DialogPtr dialog = (DialogPtr) FrontWindow();
-
- if ( dialog )
- {
- EventRecord event;
-
- event.what = activateEvt;
- event.message = (long) dialog;
- event.modifiers = 0;
-
- CallModalFilterProc(filterProc, dialog, &event, 0);
- }
- }
-
- //------------------------------------------------------------------------------
- // PasteAsFilterProc
- //------------------------------------------------------------------------------
-
- static pascal Boolean
- PasteAsFilterProc(DialogPtr dialog, EventRecord *event, short *itemHit)
- {
- // If the event is a deactivate event, the ok button must be deactivated
- // before the surrounding outline is drawn so it is drawn dim.
- ODBoolean rslt = ODButtonKeyFilterProc(dialog,event,itemHit);
-
- if ( event->what == activateEvt )
- {
- ODOutlineDefaultButtonDrawProc(dialog, kPasteAsDefaultButtonItem);
- }
-
- return rslt;
- }
-
- //------------------------------------------------------------------------------
- // ShowPasteAsDialog
- //------------------------------------------------------------------------------
-
- ODError ShowPasteAsDialogEx(
- ODBoolean canPasteLink,
- ODPasteAsMergeSetting mergeSetting,
- ODBoolean isMove,
- ODStorageUnit* contentSU,
- ODFacet* facet,
- ODTypeToken viewType,
- ODPasteAsResult* result,
- ODBoolean* boolResult)
-
- {
- Environment* ev = somGetGlobalEnvironment();
- ODError err = noErr;
-
- WindowPtr savePort; ODVolatile(savePort);
- GetPort(&savePort);
-
- short itemHit = kPasteAsCancelBtn;
- short itemType;
- DialogPtr dlg = kODNULL; ODVolatile(dlg);
- Handle itemHandle;
- Rect itemRect;
- Rect kindPopupRect;
- Rect editorPopupRect;
- short kindItemSelected;
- short kindItemOthers;
- short kindItemCurrent;
- ODBoolean kindPopupHasNoTranslationKind = kODTrue;
- ODUShort translationIndex = 0;
-
- ODSLong refSaved;
- OSErr resErr;
-
- ODBoolean userChangedKind = kODFalse;
-
- ControlHandle kindPopupControlHandle;
- ControlHandle editorPopupControlHandle;
-
- ODEditor mergeEditorID = kODNULL; ODVolatile(mergeEditorID);
- ODEditor embedEditorID = kODNULL; ODVolatile(embedEditorID);
- ODEditor preferredEditorID = kODNULL; ODVolatile(preferredEditorID);
-
- EditorSet* editorList = kODNULL; ODVolatile(editorList);
-
- ODSShort bestKindIndex = 1;
- ODSShort bestMergeKind = 1;
-
- ODType bestKind = kODNULL; ODVolatile(bestKind);
- ODTypeList* kindList = kODNULL; ODVolatile(kindList);
- ODTypeList* translateToList = kODNULL; ODVolatile(translateToList);
- OrderedCollection* translateFromList = kODNULL; ODVolatile(translateFromList);
-
- MenuHandle kindMenu = kODNULL; ODVolatile(kindMenu);
- MenuHandle editorMenu = kODNULL; ODVolatile(editorMenu);
-
- UserItemUPP DrawBoxItemUPP = kODNULL; ODVolatile(DrawBoxItemUPP);
- UserItemUPP DrawDeactiveItemUPP = kODNULL; ODVolatile(DrawDeactiveItemUPP);
- UserItemUPP DrawEditorNameUPP = kODNULL; ODVolatile(DrawEditorNameUPP);
- UserItemUPP DrawEmbeddedEditorNameUPP = kODNULL;ODVolatile(DrawEmbeddedEditorNameUPP);
- UserItemUPP DrawKindNameUPP = kODNULL; ODVolatile(DrawKindNameUPP);
-
- ModalFilterUPP modalFilter = kODNULL; ODVolatile(modalFilter);
-
- if ( canPasteLink )
- canPasteLink = contentSU->Exists(ev, kODPropLinkSpec, (ODValueType) kODLinkSpec, 0);
-
- result->pasteLinkSetting = (!isMove) && canPasteLink;
- result->autoUpdateSetting = kODTrue;
- result->selectedKind = (ODType) kODNULL;
- result->translateKind = (ODType) kODNULL;
- result->editor = kODNoEditor;
-
- ODSession* session;
- {
- TempODPart part = facet->GetFrame(ev)->AcquirePart(ev);
- session = part->GetStorageUnit(ev)->GetSession(ev);
- }
-
-
- TRY
- ODBinding* binding = session->GetBinding(ev);
- InitBindingNamespaceUtils(session);
-
- ODNameSpaceManager* nsm = session->GetNameSpaceManager(ev);
-
- session->GetWindowState(ev)->DeactivateFrontWindows(ev);
-
- { TempODPart part = facet->GetFrame(ev)->AcquirePart(ev);
- mergeEditorID = GetCurrentEditorForPart(part);
- }
-
- kindList = session->GetStorageSystem(ev)->CreateTypeList(ev, (ODTypeList*) kODNULL);
- ContentValueTypes(contentSU, kindList);
-
- // Now get all possible translations from the available kinds
- translateToList = session->GetStorageSystem(ev)->CreateTypeList(ev, (ODTypeList*) kODNULL);
- translateFromList = new OrderedCollection;
- TranslateValueTypes(kindList, translateToList, translateFromList, session);
-
- refSaved = BeginUsingLibraryResources();
- kindMenu = GetMenu(kPasteAsKindPopupMenu);
- resErr = ResError();
- EndUsingLibraryResources(refSaved);
- THROW_IF_NULL(kindMenu, resErr ? resErr : resNotFound);
-
- AddTypesToMenu(kindList, kindMenu, kODNULL, kODNULL, session);
- kindItemOthers = CountMItems(kindMenu);
-
- ODBoolean canMerge = (mergeSetting != kODPasteAsEmbedOnly);
- ODBoolean canEmbed = (mergeSetting != kODPasteAsMergeOnly);
-
- result->mergeSetting = (mergeSetting == kODPasteAsMerge) || (mergeSetting == kODPasteAsMergeOnly);
-
- {
- CUsingLibraryResources r;
- dlg = ODGetNewDialog(ev, kPasteAsDlgID, session, kNoDefaultButton);
- THROW_IF_NULL(dlg);
- SetPort(dlg);
- SetDialogTextStyle(dlg, kPasteAsDlgID, smCurrentScript);
- }
-
- DialogSetUpAppleGuide( dlg, kPasteAsAGButton );
-
- /* Horizontal line needs to be drawn */
- GetDialogItem(dlg, kPasteAsHorizSep, &itemHit, &itemHandle, &itemRect);
- DrawBoxItemUPP = NewUserItemProc(DrawGrayBoxItem);
- SetDialogItem(dlg, kPasteAsHorizSep, itemHit, (Handle)DrawBoxItemUPP, &itemRect);
-
- // Set the draw routine for the default button outline item
- GetDialogItem(dlg, kPasteAsDefaultButtonItem, &itemHit, &itemHandle, &itemRect);
- SetDialogItem(dlg, kPasteAsDefaultButtonItem, itemHit, (Handle)GetODOutlineDefaultButtonDrawProc(), &itemRect);
-
- // Create one UPP for all user items used to draw deactive PICTs
- DrawDeactiveItemUPP = NewUserItemProc(DrawDeactivePICTItem);
-
- // Initialize state of "Paste with Link" checkbox and label
- SetupControlItem(dlg, kPasteAsLinkCheckbox, result->pasteLinkSetting, canPasteLink);
-
- // Initialize state of "Get Updates" radio buttons and labels
- if ( result->pasteLinkSetting)
- HideDialogItem(dlg, kPasteAsUpdateDisabledText);
- else
- HideDialogItem(dlg, kPasteAsUpdateText);
-
- SetupControlItem(dlg, kPasteAsAutomaticRadioBtn, result->autoUpdateSetting, result->pasteLinkSetting);
- SetupControlItem(dlg, kPasteAsManualRadioBtn, !result->autoUpdateSetting, result->pasteLinkSetting);
-
- // set up merge picture, radio button, and label
- InitItemActive(dlg, kPasteAsMergePict, DrawDeactiveItemUPP, canMerge);
- SetupControlItem(dlg, kPasteAsMergeRadioBtn, result->mergeSetting, canMerge);
-
- // set up embed picture, radio button, and label
- InitItemActive(dlg, kPasteAsEmbedPict, DrawDeactiveItemUPP, canEmbed);
- SetupControlItem(dlg, kPasteAsEmbedRadioBtn, !result->mergeSetting, canEmbed);
-
- // set up initial "Paste as:" popup selection
- InitialViewSelection(dlg, viewType, session);
-
- // inactivate the "Embed as:" popup if merge is initially selected
- if ( result->mergeSetting )
- {
- GetDialogItem(dlg, kPasteAsEmbedPopup, &itemType, &itemHandle, &itemRect);
- ASSERT_CONTROL_ITEM(itemType);
- HiliteControl((ControlHandle)itemHandle, kControlInactive);
- }
-
- // Determine the indices of the best kind and the best kind that can be merged
- bestKind = BestContentKind(contentSU);
- if ( bestKind )
- bestKindIndex = IndexOfKindInList(kindList, bestKind);
- if ( bestKindIndex == 0 ) // In case preferred kind property is bogus
- bestKindIndex = 1;
-
- bestMergeKind = BestMergeKindSetting(kindList, bestKind, mergeEditorID, nsm);
-
- // Suppress the preferred editor if it doesn't support the preferred kind
- preferredEditorID = ODGetISOStrProp(ev, contentSU, kODPropPreferredEditor, kODEditor, kODNULL, kODNULL);
- if ( preferredEditorID && bestKind && !EditorSupportsKind(nsm, preferredEditorID, bestKind) )
- {
- ODDisposePtr((ODPtr) preferredEditorID);
- preferredEditorID = kODNULL;
- }
-
- #if ODDebugLinkDlgs
- somPrintf("ShowPasteAsDialog: mergeSetting = %u, best merge kind = %u\n", mergeSetting, (bestMergeKind != 0));
- #endif
-
- // Set up the Kind popup items
- EnableKindPopupItems(result->mergeSetting, kindList, translateToList, 0, kindMenu, mergeEditorID, nsm);
- GetDialogItem(dlg, kPasteAsKindPopup, &itemType, (Handle*) &kindPopupControlHandle, &kindPopupRect);
- ASSERT_CONTROL_ITEM(itemType);
- SetControlValue(kindPopupControlHandle, result->mergeSetting ? bestMergeKind : bestKindIndex);
-
- // Determine if the root storage unit is an existing part from the same draft
- // as the pasting part
-
- ODDraft* partDraft;
- // Get the draft from the part, not the frame, because the frame's storage
- // unit is null if non-persistent.
- {
- TempODPart part = facet->GetFrame(ev)->AcquirePart(ev);
- partDraft = part->GetStorageUnit(ev)->GetDraft(ev);
- }
- ODBoolean contentIsPart = SUClonedFromDraft(ev, contentSU, partDraft);
-
- // Set text of static "Kind:" label
- DisposeGlobalODNameAndZeroPtr(&gKindName);
- if ( bestKind && GetUserKindFromKind(nsm, bestKind, &gKindName) )
- {
- GetDialogItem(dlg, kPasteAsKindText, &itemType, &itemHandle, &itemRect);
- DrawKindNameUPP = NewUserItemProc(DrawKindName);
- SetDialogItem(dlg, kPasteAsKindText, userItem+itemDisable, (Handle) DrawKindNameUPP, &itemRect);
- }
-
- // inactivate the "Kind:" popup if embedding is initially selected, the operation is
- // a move, and a cloned part is in the storage unit (not intrinsic content).
- if ( (!result->mergeSetting) && isMove && contentIsPart )
- {
- HideDialogItem(dlg, kPasteAsKindPopup);
- }
- else
- {
- HideDialogItem(dlg, kPasteAsKindLabel);
- HideDialogItem(dlg, kPasteAsKindText);
- }
-
- // Setup the static text for the merge editor
- DisposeGlobalODNameAndZeroPtr(&gEditorName);
- if ( mergeEditorID && GetUserEditorFromEditor(nsm, mergeEditorID, &gEditorName) )
- {
- GetDialogItem(dlg, kPasteAsEditorText, &itemType, &itemHandle, &itemRect);
- DrawEditorNameUPP = NewUserItemProc(DrawEditorName);
- SetDialogItem(dlg, kPasteAsEditorText, userItem+itemDisable, (Handle) DrawEditorNameUPP, &itemRect);
- }
-
- // Setup the static text for the embedding editor
- // Since the contentSU will not be cloned during a move in the same document, this is a guess as to the
- // editor actually bound to the moved frame.
- if ( preferredEditorID )
- embedEditorID = ODISOStrFromCStr((char *) preferredEditorID);
- else
- embedEditorID = binding->ChooseEditorForPart(ev, contentSU, bestKind);
-
- DisposeGlobalODNameAndZeroPtr(&gEmbeddedEditorName);
- if ( embedEditorID && GetUserEditorFromEditor(nsm, embedEditorID, &gEmbeddedEditorName) )
- {
- GetDialogItem(dlg, kPasteAsEmbedEditorText, &itemType, &itemHandle, &itemRect);
- DrawEmbeddedEditorNameUPP = NewUserItemProc(DrawEmbeddedEditorName);
- SetDialogItem(dlg, kPasteAsEmbedEditorText, userItem+itemDisable, (Handle) DrawEmbeddedEditorNameUPP, &itemRect);
- }
-
- // Setup the editor popup
- editorList = new EditorSet;
- editorList->InitEditorSet();
-
- refSaved = BeginUsingLibraryResources();
- editorMenu = GetMenu(kPasteAsEditorPopupMenu);
- resErr = ResError();
- EndUsingLibraryResources(refSaved);
- THROW_IF_NULL(editorMenu, resErr ? resErr : resNotFound);
-
- GetDialogItem(dlg, kPasteAsEditorPopup, &itemType, (Handle*) &editorPopupControlHandle, &editorPopupRect);
- SetupEditorMenu(bestKind, editorList, editorMenu, editorPopupControlHandle, session);
-
- if ( result->mergeSetting )
- {
- HideDialogItem(dlg, kPasteAsEditorPopup);
- HideDialogItem(dlg, kPasteAsEmbedEditorText);
- }
- else if ( isMove && contentIsPart )
- {
- HideDialogItem(dlg, kPasteAsEditorPopup);
- HideDialogItem(dlg, kPasteAsEditorText);
- }
- else
- {
- HideDialogItem(dlg, kPasteAsEditorLabel);
- HideDialogItem(dlg, kPasteAsEmbedEditorText);
- HideDialogItem(dlg, kPasteAsEditorText);
- }
-
- modalFilter = NewModalFilterProc(PasteAsFilterProc);
-
- // Display the dialog
- ShowWindow(dlg);
-
- do {
- // Remember the currently selected kind
- kindItemCurrent = (ODSShort) GetControlValue(kindPopupControlHandle);
-
- { CUsingLibraryResources r;
- ModalDialog(modalFilter, &itemHit);
- }
-
- switch (itemHit)
- {
- case kPasteAsLinkCheckbox:
- result->pasteLinkSetting = !result->pasteLinkSetting;
- GetDialogItem(dlg, itemHit, &itemType, &itemHandle, &itemRect);
- ASSERT_CONTROL_ITEM(itemType);
- SetControlValue((ControlHandle)itemHandle, result->pasteLinkSetting);
-
- if ( result->pasteLinkSetting )
- {
- GetDialogItem(dlg, kPasteAsUpdateDisabledText, &itemType, &itemHandle, &itemRect);
- itemRect.left += 16384;
- itemRect.right += 16384;
- SetDialogItem(dlg, kPasteAsUpdateDisabledText, itemType, itemHandle, &itemRect);
- ShowDialogItem(dlg, kPasteAsUpdateText);
- }
- else
- {
- GetDialogItem(dlg, kPasteAsUpdateText, &itemType, &itemHandle, &itemRect);
- itemRect.left += 16384;
- itemRect.right += 16384;
- SetDialogItem(dlg, kPasteAsUpdateText, itemType, itemHandle, &itemRect);
- ShowDialogItem(dlg, kPasteAsUpdateDisabledText);
- }
-
- SetupControlItem(dlg, kPasteAsAutomaticRadioBtn, result->autoUpdateSetting, result->pasteLinkSetting);
- SetupControlItem(dlg, kPasteAsManualRadioBtn, !result->autoUpdateSetting, result->pasteLinkSetting);
- break;
-
- case kPasteAsAutomaticRadioBtn:
- result->autoUpdateSetting = kODTrue;
- SetAutomaticUpdateControls(dlg, result->autoUpdateSetting);
- break;
-
- case kPasteAsManualRadioBtn:
- result->autoUpdateSetting = kODFalse;
- SetAutomaticUpdateControls(dlg, result->autoUpdateSetting);
- break;
-
- case kPasteAsMergePict:
- case kPasteAsMergeRadioBtn:
- if ( !result->mergeSetting )
- {
- result->mergeSetting = kODTrue;
- SetMergeEmbedControls(dlg, result->mergeSetting);
-
- TempODType selectedKind = kODNULL;
- if ( kindItemCurrent <= kindList->Count(ev) )
- selectedKind = GetSelectedType(kindList, kindItemCurrent);
- else
- selectedKind = GetSelectedType(translateToList, translationIndex);
-
- if ( !EditorSupportsKind(nsm, mergeEditorID, selectedKind) )
- {
- SetPopupControlValue(kindPopupControlHandle, bestMergeKind);
- userChangedKind = kODFalse; // Allow embed to automatically select best kind
- }
-
- EnableKindPopupItems(result->mergeSetting, kindList, translateToList, translationIndex, kindMenu, mergeEditorID, nsm);
-
- if ( isMove && contentIsPart )
- {
- HideDialogItem(dlg, kPasteAsKindLabel);
- HideDialogItem(dlg, kPasteAsKindText);
- ShowDialogItem(dlg, kPasteAsKindPopup);
- }
- else
- {
- EnablePasteAsOkButton(dlg, kindMenu);
- }
-
- HideDialogItem(dlg, kPasteAsEditorPopup);
- HideDialogItem(dlg, kPasteAsEmbedEditorText);
- ShowDialogItem(dlg, kPasteAsEditorLabel);
- ShowDialogItem(dlg, kPasteAsEditorText);
- }
- break;
-
- case kPasteAsEmbedPict:
- case kPasteAsEmbedRadioBtn:
- if ( result->mergeSetting )
- {
- result->mergeSetting = kODFalse;
- SetMergeEmbedControls(dlg, result->mergeSetting);
-
- // If the user has not changed the kind setting, switch to the preferred kind
- kindItemSelected = (ODSShort) GetControlValue(kindPopupControlHandle);
- if ( !userChangedKind )
- {
- // Make sure item is enabled before drawing it!
- EnableItem(kindMenu, bestKindIndex);
- SetPopupControlValue(kindPopupControlHandle, bestKindIndex);
- kindItemSelected = bestKindIndex;
- }
-
- // When embedding is chosen, determine the preferred editor, then enable the kind menu
- ResetEditorPopup(kindList,
- kindItemSelected,
- translateToList,
- translationIndex,
- editorList,
- editorMenu,
- editorPopupControlHandle,
- session);
-
- // Select the preferred editor if specified
- ODSShort preferredEditorItem = IndexOfEditorInList(editorList, preferredEditorID);
- if ( preferredEditorItem != 0 )
- SetPopupControlValue(editorPopupControlHandle, preferredEditorItem);
-
- if ( isMove && contentIsPart )
- {
- HideDialogItem(dlg, kPasteAsEditorText);
- ShowDialogItem(dlg, kPasteAsEmbedEditorText);
- }
- else
- {
- HideDialogItem(dlg, kPasteAsEditorLabel);
- HideDialogItem(dlg, kPasteAsEditorText);
- ShowDialogItem(dlg, kPasteAsEditorPopup);
- }
-
- // Now enable the kind items
- if ( isMove && contentIsPart )
- {
- HideDialogItem(dlg, kPasteAsKindPopup);
- ShowDialogItem(dlg, kPasteAsKindLabel);
- ShowDialogItem(dlg, kPasteAsKindText);
- }
- else
- {
- ODSShort editorItem = (ODSShort) GetControlValue(editorPopupControlHandle);
- ODEditor selectedEditor = GetSelectedEditor(editorList, editorItem);
- EnableKindPopupItems(result->mergeSetting, kindList, translateToList, translationIndex, kindMenu, selectedEditor, nsm);
- ODDisposePtr((ODPtr) selectedEditor);
- EnablePasteAsOkButton(dlg, kindMenu);
- }
- }
- break;
-
- case kPasteAsKindPopup:
- kindItemSelected = (ODSShort) GetControlValue(kindPopupControlHandle);
- if ( kindItemSelected == kindItemOthers )
- {
- ODUShort selectedIndex;
- ODSShort editorItem = (ODSShort) GetControlValue(editorPopupControlHandle);
- ODEditor initialEditorID;
- if ( result->mergeSetting )
- initialEditorID = ODISOStrFromCStr((char *) mergeEditorID);
- else
- initialEditorID = GetSelectedEditor(editorList, editorItem);
- ODEditor newEditorID = kODNULL;
-
- // Return the kind popup to its current value
- SetPopupControlValue(kindPopupControlHandle, kindItemCurrent);
- DeactivateModalDialog(modalFilter);
-
- if ( session->GetTranslation(ev)->ShowTranslateDialog(
- ev,
- translateToList,
- translationIndex,
- &selectedIndex,
- initialEditorID,
- !result->mergeSetting,
- &newEditorID) )
- {
- // Add translationKind to the list just above "Translate to…",
- // and make it the current selection.
- translationIndex = selectedIndex;
-
- { TempODType translationKind = GetSelectedType(translateToList, translationIndex);
- AddTranslationKindToMenu(translationKind, kindMenu, kindItemOthers-1,
- kindPopupHasNoTranslationKind, session);
- }
-
- if ( kindPopupHasNoTranslationKind )
- {
- kindPopupHasNoTranslationKind = kODFalse;
- kindItemOthers += 1;
- }
-
- SetPort(dlg);
- SetControlValue(kindPopupControlHandle, kindItemOthers-1);
- InvalRect(&kindPopupRect); // Redraw the popup
-
- if ( !result->mergeSetting )
- {
- ResetEditorPopup(kindList,
- kindItemSelected,
- translateToList,
- translationIndex,
- editorList,
- editorMenu,
- editorPopupControlHandle,
- session);
- // Select editorID in the list
- ODSShort editorItem = IndexOfEditorInList(editorList, newEditorID);
- if ( editorItem != 0 )
- SetControlValue(editorPopupControlHandle, editorItem);
- InvalRect(&editorPopupRect); // Redraw the popup
- }
- ODDisposePtr((ODPtr) initialEditorID);
- ODDisposePtr((ODPtr) newEditorID);
-
- userChangedKind = kODTrue;
- }
- }
- else if ( kindItemSelected != kindItemCurrent )
- {
- userChangedKind = kODTrue;
- if ( !result->mergeSetting )
- {
- // Remember the currently selected editor
- ODSShort editorItem = (ODSShort) GetControlValue(editorPopupControlHandle);
- TempODEditor lastEditorID = GetSelectedEditor(editorList, editorItem);
-
- ResetEditorPopup(kindList,
- kindItemSelected,
- translateToList,
- translationIndex,
- editorList,
- editorMenu,
- editorPopupControlHandle,
- session);
-
- // Reselect the last editor if it supports the new kind
- TempODType selectedKind = kODNULL;
- if ( kindItemCurrent <= kindList->Count(ev) )
- selectedKind = GetSelectedType(kindList, kindItemCurrent);
- else
- selectedKind = GetSelectedType(translateToList, translationIndex);
-
- ODSShort newEditorItem = 0;
- if ( EditorSupportsKind(nsm, lastEditorID, selectedKind) )
- {
- newEditorItem = IndexOfEditorInList(editorList, lastEditorID);
- }
- if ( newEditorItem != 0 )
- SetPopupControlValue(editorPopupControlHandle, newEditorItem);
- else
- {
- SetPort(dlg);
- InvalRect(&editorPopupRect); // Redraw the popup
- }
- }
- }
- EnablePasteAsOkButton(dlg, kindMenu);
- break;
- #ifdef _APPLEGUIDE_READY_
- case kPasteAsAGButton:
- OpenAppleGuide();
- break;
- #endif
- default:
- break;
- }
- } while ((itemHit != kPasteAsOKBtn) && (itemHit != kPasteAsCancelBtn));
-
- if ( itemHit == kPasteAsOKBtn )
- {
- // update from "View" popup
- if ( !result->mergeSetting )
- result->selectedView = GetViewSelected(dlg, session);
-
- // update from "Kind" popup
- if ( (!result->mergeSetting) && isMove && contentIsPart )
- {
- // Selected kind is the best kind
- result->selectedKind = GetSelectedType(kindList, bestKindIndex);
- }
- else
- {
- ODSShort kindItem = (ODSShort) GetControlValue(kindPopupControlHandle);
- ODSShort kindCount = (ODSShort) kindList->Count(ev);
- if (kindItem <= kindCount)
- {
- result->selectedKind = GetSelectedType(kindList, kindItem);
- }
- else
- {
- result->selectedKind = GetSelectedType(translateToList, translationIndex);
- result->translateKind = GetSelectedType(kindList, GetIndexedElement(translateFromList, translationIndex));
- }
- }
-
- // update from "Editor" popup
- if ( (!result->mergeSetting) && (!isMove || !contentIsPart) )
- {
- ODSShort editorItem = (ODSShort) GetControlValue(editorPopupControlHandle);
- result->editor = GetSelectedEditor(editorList, editorItem);
- }
- }
-
- CATCH_ALL
- ODDisposeRoutineDescriptor(DrawBoxItemUPP);
- ODDisposeRoutineDescriptor(DrawDeactiveItemUPP);
- ODDisposeRoutineDescriptor(DrawKindNameUPP);
- ODDisposeRoutineDescriptor(DrawEditorNameUPP);
- ODDisposeRoutineDescriptor(DrawEmbeddedEditorNameUPP);
- ODDisposeRoutineDescriptor(modalFilter);
-
- refSaved = BeginUsingLibraryResources();
- if ( kindMenu )
- {
- DeleteMenu(kPasteAsKindPopupMenu);
- ReleaseResource((Handle) kindMenu);
- }
- if ( editorMenu )
- {
- DeleteMenu(kPasteAsEditorPopupMenu);
- ReleaseResource((Handle) editorMenu);
- }
- ODDisposeDialog(dlg);
- EndUsingLibraryResources(refSaved);
-
- ODDisposePtr((ODPtr) mergeEditorID);
- ODDisposePtr((ODPtr) embedEditorID);
- ODDisposePtr((ODPtr) preferredEditorID);
- ODDisposePtr((ODPtr) bestKind);
-
- ODDeleteObject(kindList);
- ODDeleteObject(translateToList);
- ODDeleteObject(translateFromList);
- delete editorList; editorList = kODNULL;
-
- DisposeGlobalODNameAndZeroPtr(&gEditorName);
- DisposeGlobalODNameAndZeroPtr(&gEmbeddedEditorName);
-
- SetPort(savePort);
- // RERAISE;
- err = ErrorCode();
- ENDTRY;
-
- DisposeRoutineDescriptor(DrawBoxItemUPP);
- DisposeRoutineDescriptor(DrawDeactiveItemUPP);
- DisposeRoutineDescriptor(DrawKindNameUPP);
- DisposeRoutineDescriptor(DrawEditorNameUPP);
- DisposeRoutineDescriptor(DrawEmbeddedEditorNameUPP);
- DisposeRoutineDescriptor(modalFilter);
-
- refSaved = BeginUsingLibraryResources();
- if ( kindMenu )
- {
- DeleteMenu(kPasteAsKindPopupMenu);
- ReleaseResource((Handle) kindMenu);
- }
- if ( editorMenu )
- {
- DeleteMenu(kPasteAsEditorPopupMenu);
- ReleaseResource((Handle) editorMenu);
- }
- DisposeDialog(dlg);
- EndUsingLibraryResources(refSaved);
-
- ODDisposePtr((ODPtr) mergeEditorID);
- ODDisposePtr((ODPtr) embedEditorID);
- ODDisposePtr((ODPtr) preferredEditorID);
- ODDisposePtr((ODPtr) bestKind);
-
- ODDeleteObject(kindList);
- ODDeleteObject(translateToList);
- ODDeleteObject(translateFromList);
- delete editorList; editorList = kODNULL;
-
- DisposeGlobalODNameAndZeroPtr(&gEditorName);
- DisposeGlobalODNameAndZeroPtr(&gEmbeddedEditorName);
-
- session->GetWindowState(ev)->ActivateFrontWindows(ev);
-
- SetPort(savePort);
-
- *boolResult = (itemHit == kPasteAsOKBtn);
- return err;
- }
-
- //------------------------------------------------------------------------------
- // ResetEditorPopup
- //------------------------------------------------------------------------------
-
- ODStatic void ResetEditorPopup(ODTypeList* kindList,
- ODUShort kindIndex,
- ODTypeList* translateToList,
- ODUShort translateToIndex,
- EditorSet* editorList,
- MenuHandle editorMenu,
- ControlHandle popupCtlHndl,
- ODSession* session)
- {
- Environment* ev = somGetGlobalEnvironment();
- TempODType kind = kODNULL;
-
- ODSShort kindCount = (ODSShort) kindList->Count(ev);
- if (kindIndex <= kindCount)
- kind = GetSelectedType(kindList, kindIndex);
- else
- kind = GetSelectedType(translateToList, translateToIndex);
-
- editorList->RemoveAllEditors();
- SetupEditorMenu(kind,
- editorList,
- editorMenu,
- popupCtlHndl,
- session);
- }
-
- //------------------------------------------------------------------------------
- // PrepareToDrawGray
- //------------------------------------------------------------------------------
- //
- // Sets the foreground color to the best color midway between the forground and
- // background colors; usually gray. If no intermediate gray is available (4 or
- // fewer colors available), the pen pattern is set to draw gray.
-
- ODStatic Boolean PrepareToDrawGray(DialogPtr theDialog, short theItem, RGBColor* fgSaveColor)
- {
- Boolean result = false;
- const short kColorPort = 0xC000;
-
- Boolean isColorPort = ((((CGrafPtr)theDialog)->portVersion & kColorPort) == kColorPort);
-
- if ( isColorPort )
- {
- RGBColor fgNewColor;
- RGBColor bgColor;
-
- Rect itemRect;
- Handle itemHandle;
- short itemKind;
-
- GetBackColor(&bgColor);
- GetForeColor(fgSaveColor);
- fgNewColor = *fgSaveColor;
-
- GetDialogItem(theDialog, kPasteAsOKBtn, &itemKind, &itemHandle, &itemRect);
-
- Rect globalRect = itemRect;
- LocalToGlobal((Point *)&(globalRect.top));
- LocalToGlobal((Point *)&(globalRect.bottom));
- GDHandle targetDevice = GetMaxDevice(&globalRect);
-
- result = GetGray(targetDevice, &bgColor, &fgNewColor);
-
- if ( result )
- RGBForeColor(&fgNewColor);
- }
-
- if ( !result )
- {
- #ifdef THINK_CPLUS
- PenPat(ODQDGlobals.gray);
- #else
- PenPat(&ODQDGlobals.gray);
- #endif
- }
-
- return result;
- }
-
- //------------------------------------------------------------------------------
- // DrawDeactivePICTItem
- //------------------------------------------------------------------------------
- //
- // Draws a dimmed image of the preceeding dialog item, which should be
- // beyond the visible area of the dialog, in this item's rectangle.
-
- ODStatic pascal void DrawDeactivePICTItem(DialogPtr theDialog, short theItem)
- {
- Rect itemRect, otherRect;
- Handle itemHandle, otherHandle;
- short itemKind, otherKind;
-
- WindowPtr savePort;
- PenState savePen;
-
- RGBColor fgSaveColor;
- Boolean isColor;
-
- GetPort(&savePort);
- SetPort(theDialog);
- GetPenState(&savePen);
- PenNormal();
-
- // Get this dialog item
- GetDialogItem(theDialog, theItem, &itemKind, &itemHandle, &itemRect);
-
- // Get the dialog item to be drawn disabled
- GetDialogItem(theDialog, theItem-1, &otherKind, &otherHandle, &otherRect);
- if ( (otherKind & ~itemDisable) == picItem )
- {
- DrawPicture((PicHandle) otherHandle, &itemRect);
- isColor = PrepareToDrawGray(theDialog, theItem, &fgSaveColor);
- if ( isColor )
- PenMode(addMax);
- else
- PenMode(patBic);
- PaintRect(&itemRect);
- if ( isColor )
- RGBForeColor(&fgSaveColor);
- }
-
- SetPenState(&savePen);
- SetPort(savePort);
- }
-
- //------------------------------------------------------------------------------
- // InitItemActive
- //------------------------------------------------------------------------------
-
- ODStatic void InitItemActive(
- DialogPtr dlg,
- short itemNumber,
- UserItemUPP itemUPP,
- ODBoolean itemActive)
- {
- Rect itemRect, otherRect;
- Handle itemHandle, otherHandle;
- short itemKind, otherKind;
-
- // Get the rectangle from the actual item
- GetDialogItem(dlg, itemNumber, &otherKind, &otherHandle, &otherRect);
-
- // Establish the draw routine and rectangle for the user item
- GetDialogItem(dlg, itemNumber+1, &itemKind, &itemHandle, &itemRect);
- SetDialogItem(dlg, itemNumber+1, itemKind, (Handle)itemUPP, &otherRect);
-
- if ( itemActive )
- HideDialogItem(dlg, itemNumber+1);
- else
- HideDialogItem(dlg, itemNumber);
- }
-
- //------------------------------------------------------------------------------
- // SetControlActive
- //------------------------------------------------------------------------------
- ODStatic void SetControlActive(
- DialogPtr dlg,
- short itemNumber,
- ODBoolean itemActive)
- {
- short itemType;
- Handle itemHandle;
- Rect itemRect;
-
- GetDialogItem(dlg, itemNumber, &itemType, &itemHandle, &itemRect);
- ASSERT_CONTROL_ITEM(itemType);
- HiliteControl((ControlHandle)itemHandle, itemActive ? kControlActive : kControlInactive);
- }
-
- //------------------------------------------------------------------------------
- // BestContentKind
- //------------------------------------------------------------------------------
- ODStatic ODType BestContentKind(ODStorageUnit* contentSU)
- {
- Environment* ev = somGetGlobalEnvironment();
-
- ODType bestKind = ODGetISOStrProp(ev, contentSU, kODPropPreferredKind, kODISOStr, kODNULL, kODNULL);
-
- if ( bestKind == kODNULL )
- {
- if (contentSU->Exists(ev, kODPropContents, (ODValueType)kODNULL, 1))
- {
- contentSU->Focus(ev, kODPropContents, kODPosUndefined, (ODValueType)kODNULL, 1, kODPosUndefined);
- bestKind = contentSU->GetType(ev);
- }
- }
-
- return bestKind;
- }
-
- //------------------------------------------------------------------------------
- // SetLinkUpdateUpdateControls
- //------------------------------------------------------------------------------
- ODStatic void SetLinkUpdateUpdateControls(DialogPtr dlg, ODBoolean autoUpdateSetting)
- {
- short itemType;
- Handle itemHandle;
- Rect itemRect;
-
- GetDialogItem(dlg, kLinkInfoOnSaveRadioBtn, &itemType, &itemHandle, &itemRect);
- ASSERT_CONTROL_ITEM(itemType);
- SetControlValue((ControlHandle)itemHandle, autoUpdateSetting);
- GetDialogItem(dlg, kLinkInfoManualRadioBtn, &itemType, &itemHandle, &itemRect);
- ASSERT_CONTROL_ITEM(itemType);
- SetControlValue((ControlHandle)itemHandle, !autoUpdateSetting);
- }
-
- //------------------------------------------------------------------------------
- // LinkInfoFilterProc
- //------------------------------------------------------------------------------
-
- static pascal Boolean
- LinkInfoFilterProc(DialogPtr dialog, EventRecord *event, short *itemHit)
- {
- // If the event is a deactivate event, the ok button must be deactivated
- // before the surrounding outline is drawn so it is drawn dim.
- ODBoolean rslt = ODButtonKeyFilterProc(dialog,event,itemHit);
-
- if ( event->what == activateEvt )
- {
- ODOutlineDefaultButtonDrawProc(dialog, kLinkInfoDefaultButtonItem);
- }
-
- return rslt;
- }
-
- //------------------------------------------------------------------------------
- // ShowLinkInfo
- //------------------------------------------------------------------------------
-
- ODStatic ODBoolean ShowLinkInfo(
- DialogPtr dlg,
- ConstStr255Param creationDate,
- ConstStr255Param creationTime,
- ConstStr255Param modificationDate,
- ConstStr255Param modificationTime,
- ODBoolean needsUpdate,
- ODLinkInfoResult* infoResult
- )
- {
- short itemHit;
-
- ParamText(creationDate, creationTime, modificationDate, modificationTime);
-
- ShowWindow(dlg);
-
- ModalFilterUPP modalFilter = NewModalFilterProc(LinkInfoFilterProc);
-
- do {
- ODSLong refSaved = BeginUsingLibraryResources();
- ModalDialog(modalFilter, &itemHit);
- EndUsingLibraryResources(refSaved);
-
- switch (itemHit)
- {
- case kLinkInfoManualRadioBtn :
- if ( infoResult->autoUpdate )
- {
- infoResult->autoUpdate = kODFalse;
- SetLinkUpdateUpdateControls(dlg, infoResult->autoUpdate);
- SetControlActive(dlg, kLinkInfoUpdateBtn, needsUpdate);
- }
- break;
-
- case kLinkInfoOnSaveRadioBtn :
- if ( !infoResult->autoUpdate )
- {
- infoResult->autoUpdate = kODTrue;
- SetLinkUpdateUpdateControls(dlg, infoResult->autoUpdate);
- SetControlActive(dlg, kLinkInfoUpdateBtn, kODFalse);
- }
- break;
- #ifdef _APPLEGUIDE_READY_
- case kLinkInfoAGButton:
- OpenAppleGuide();
- break;
- #endif
- }
- } while ((itemHit != kLinkInfoOKBtn) && (itemHit != kLinkInfoCancelBtn) &&
- (itemHit != kLinkInfoUpdateBtn) && (itemHit != kLinkInfoBreakLinkBtn) &&
- (itemHit != kLinkInfoFindSrcBtn));
-
- switch (itemHit) {
- case kLinkInfoOKBtn:
- infoResult->action = kODLinkInfoOk;
- break;
- case kLinkInfoUpdateBtn:
- infoResult->action = kODLinkInfoUpdateNow;
- break;
- case kLinkInfoBreakLinkBtn:
- infoResult->action = kODLinkInfoBreakLink;
- break;
- case kLinkInfoFindSrcBtn:
- infoResult->action = kODLinkInfoFindSource;
- break;
- default:
- infoResult->action = kODLinkInfoCancel;
- break;
- }
-
- ODDisposeRoutineDescriptor(modalFilter);
-
- return (itemHit != kLinkInfoCancelBtn);
- }
-
- //------------------------------------------------------------------------------
- // DrawKindName
- //------------------------------------------------------------------------------
-
- pascal void DrawKindName(DialogPtr dialog, SInt16 item)
- {
- short itemType;
- Handle itemHandle;
- Rect itemRect;
-
- GetDialogItem(dialog, item, &itemType, &itemHandle, &itemRect);
-
- DrawITextInDlogBox(gKindName, &itemRect, dialog, kODTrue);
- }
-
- //------------------------------------------------------------------------------
- // ShowLinkSourceInfo
- //------------------------------------------------------------------------------
-
- ODError ShowLinkSourceInfoEx(
- ODBaseLinkSource* linkSource,
- ODUpdateID change,
- ODBoolean changesAllowed,
- ODLinkInfoResult* infoResult,
- ODBoolean* boolResult)
- {
- ODError err = noErr;
- Environment* ev = somGetGlobalEnvironment();
-
- WindowPtr savePort; ODVolatile(savePort);
- GetPort(&savePort);
- ODSLong refSaved;
-
- DialogPtr dlg = kODNULL; ODVolatile(dlg);
- UserItemUPP DrawBoxItemUPP = kODNULL; ODVolatile(DrawBoxItemUPP);
- UserItemUPP DrawKindNameUPP = kODNULL; ODVolatile(DrawKindNameUPP);
- short itemType;
- Handle itemHandle;
- Rect itemRect;
- Str255 creationDate, modificationDate;
- Str255 creationTime, modificationTime;
- ODType kind;
- ODBoolean needsUpdate;
- // ODBoolean result;
-
- TRY
- ODSession* session = linkSource->GetStorageUnit(ev)->GetSession(ev);
- InitBindingNamespaceUtils(session);
-
- ODNameSpaceManager* nsm = session->GetNameSpaceManager(ev);
-
- {
- CUsingLibraryResources r;
- dlg = ODGetNewDialog(ev, kLinkSrcInfoDlgID, session, kNoDefaultButton);
- THROW_IF_NULL(dlg);
- }
-
- DialogSetUpAppleGuide( dlg, kLinkInfoAGButton );
- SetPort(dlg);
-
- { CUsingLibraryResources r;
- SetDialogTextStyle(dlg, kLinkSrcInfoDlgID, smCurrentScript);
- }
-
- // Set the draw routine for the default button outline item
- GetDialogItem(dlg, kLinkInfoDefaultButtonItem, &itemType, &itemHandle, &itemRect);
- SetDialogItem(dlg, kLinkInfoDefaultButtonItem, itemType, (Handle)GetODOutlineDefaultButtonDrawProc(), &itemRect);
-
- // Vertical and horizontal lines need to be drawn
- GetDialogItem(dlg, kLinkInfoSeparator, &itemType, &itemHandle, &itemRect);
- DrawBoxItemUPP = NewUserItemProc(DrawGrayBoxItem);
- SetDialogItem(dlg, kLinkInfoSeparator, itemType, (Handle)DrawBoxItemUPP, &itemRect);
-
- ODLinkKey key;
- if (linkSource->Lock(ev, 0, &key))
- {
- TRY
- ODStorageUnit* contentSU = linkSource->GetContentStorageUnit(ev, key);
-
- // Set up kind
- kind = BestContentKind(contentSU);
- DisposeGlobalODNameAndZeroPtr(&gKindName);
- if ( kind && GetUserKindFromKind(nsm, kind, &gKindName) )
- {
- GetDialogItem(dlg, kLinkInfoKind, &itemType, &itemHandle, &itemRect);
- DrawKindNameUPP = NewUserItemProc(DrawKindName);
- SetDialogItem(dlg, kLinkInfoKind, userItem+itemDisable, (Handle) DrawKindNameUPP, &itemRect);
- }
- ODDisposePtr((ODPtr) kind);
-
- // Set up creation date
- SetDateTimeStrings(ODGetCreationDate(ev, ODGetSUFromPstObj(ev, linkSource)),
- creationDate, creationTime);
-
- // Set up modified date
- SetDateTimeStrings(linkSource->GetChangeTime(ev), modificationDate, modificationTime);
- CATCH_ALL
- linkSource->Unlock(ev, key);
- RERAISE;
- ENDTRY
-
- linkSource->Unlock(ev, key);
- }
-
- // Set up Send Updates
- SetLinkUpdateUpdateControls(dlg, infoResult->autoUpdate);
-
- needsUpdate = (change == kODUnknownUpdate) || (change != linkSource->GetUpdateID(ev));
-
- // Disable Update Now button if updates are automatic or link is up to date.
- if ( infoResult->autoUpdate || !needsUpdate )
- {
- GetDialogItem(dlg, kLinkInfoUpdateBtn, &itemType, &itemHandle, &itemRect);
- ASSERT_CONTROL_ITEM(itemType);
- HiliteControl((ControlHandle)itemHandle, kControlInactive);
- }
-
- // Disable some items if changes are not allowed or draft is read only
- if ( !changesAllowed || DraftIsReadOnly(ev, linkSource->GetStorageUnit(ev)) )
- {
- SetControlActive(dlg, kLinkInfoOnSaveRadioBtn, kODFalse);
- SetControlActive(dlg, kLinkInfoManualRadioBtn, kODFalse);
- SetControlActive(dlg, kLinkInfoBreakLinkBtn, kODFalse);
- SetControlActive(dlg, kLinkInfoUpdateBtn, kODFalse);
- }
-
- *boolResult = ShowLinkInfo(dlg, creationDate, creationTime, modificationDate,
- modificationTime, needsUpdate, infoResult);
-
- CATCH_ALL
- ODDisposeRoutineDescriptor(DrawBoxItemUPP);
- ODDisposeRoutineDescriptor(DrawKindNameUPP);
-
- refSaved = BeginUsingLibraryResources();
- ODDisposeDialog(dlg);
- EndUsingLibraryResources(refSaved);
-
- SetPort(savePort);
- // RERAISE;
- err = ErrorCode();
- ENDTRY
-
- ODDisposeRoutineDescriptor(DrawBoxItemUPP);
- ODDisposeRoutineDescriptor(DrawKindNameUPP);
-
- refSaved = BeginUsingLibraryResources();
- ODDisposeDialog(dlg);
- EndUsingLibraryResources(refSaved);
-
- SetPort(savePort);
-
- return err;
- }
-
- //------------------------------------------------------------------------------
- // SetDateTimeStrings
- //------------------------------------------------------------------------------
-
- ODStatic void SetDateTimeStrings(
- ODULong dateTime,
- Str255 dateString,
- Str255 timeString)
- {
- if ( dateTime == 0 )
- {
- CUsingLibraryResources r;
-
- StringHandle str = GetString(kODLinkInfoStrUnknownID);
- if ( str != kODNULL )
- {
- ODLockHandle((ODHandle) str);
- ODBlockMove((ODPtr) *str, (ODPtr) dateString, (ODULong) (*str[0])+1);
- ODUnlockHandle((ODHandle) str);
- ReleaseResource((Handle) str);
- }
- else
- {
- dateString[0] = (char) 0;
- }
- timeString[0] = (char) 0;
- }
- else
- {
- DateString(dateTime, abbrevDate, dateString, kODNULL);
- TimeString(dateTime, kODFalse, timeString, kODNULL);
- }
- }
-
- //------------------------------------------------------------------------------
- // DraftIsReadOnly
- //------------------------------------------------------------------------------
- ODStatic ODBoolean DraftIsReadOnly(Environment* ev, ODStorageUnit* su)
- {
- return (!HAS_WRITE_ACCESS(su->GetDraft(ev)->GetPermissions(ev)));
- }
-
- //------------------------------------------------------------------------------
- // ShowLinkDestinationInfo
- //------------------------------------------------------------------------------
-
- ODError ShowLinkDestinationInfoEx(
- ODBaseLink* link,
- ODLinkInfo* info,
- ODBoolean changesAllowed,
- ODLinkInfoResult* infoResult,
- ODBoolean* boolResult)
- {
- ODError err = noErr;
- Environment* ev = somGetGlobalEnvironment();
-
- WindowPtr savePort; ODVolatile(savePort);
- GetPort(&savePort);
- ODSLong refSaved;
-
- short itemType;
- DialogPtr dlg = kODNULL; ODVolatile(dlg);
- UserItemUPP DrawBoxItemUPP = kODNULL; ODVolatile(DrawBoxItemUPP);
- UserItemUPP DrawKindNameUPP = kODNULL; ODVolatile(DrawKindNameUPP);
- Handle itemHandle;
- Rect itemRect;
- Str255 creationDate, modificationDate;
- Str255 creationTime, modificationTime;
- ODBoolean needsUpdate;
- // ODBoolean result;
-
- TRY
- ODSession* session = link->GetStorageUnit(ev)->GetSession(ev);
- InitBindingNamespaceUtils(session);
-
- ODNameSpaceManager* nsm = session->GetNameSpaceManager(ev);
-
- {
- CUsingLibraryResources r;
- dlg = ODGetNewDialog(ev, kLinkDstInfoDlgID, session, kNoDefaultButton);
- THROW_IF_NULL(dlg);
- }
-
- DialogSetUpAppleGuide( dlg, kLinkInfoAGButton );
- SetPort(dlg);
-
- { CUsingLibraryResources r;
- SetDialogTextStyle(dlg, kLinkDstInfoDlgID, smCurrentScript);
- }
-
- // Set the draw routine for the default button outline item
- GetDialogItem(dlg, kLinkInfoDefaultButtonItem, &itemType, &itemHandle, &itemRect);
- SetDialogItem(dlg, kLinkInfoDefaultButtonItem, itemType, (Handle)GetODOutlineDefaultButtonDrawProc(), &itemRect);
-
- // Vertical and horizontal lines need to be drawn
- GetDialogItem(dlg, kLinkInfoSeparator, &itemType, &itemHandle, &itemRect);
- DrawBoxItemUPP = NewUserItemProc(DrawGrayBoxItem);
- SetDialogItem(dlg, kLinkInfoSeparator, itemType, (Handle) DrawBoxItemUPP, &itemRect);
-
- // Set up kind
- DisposeGlobalODNameAndZeroPtr(&gKindName);
- if ( info->kind && GetUserKindFromKind(nsm, info->kind, &gKindName) )
- {
- GetDialogItem(dlg, kLinkInfoKind, &itemType, &itemHandle, &itemRect);
- DrawKindNameUPP = NewUserItemProc(DrawKindName);
- SetDialogItem(dlg, kLinkInfoKind, userItem+itemDisable, (Handle) DrawKindNameUPP, &itemRect);
- }
-
- // Set up creation date
- SetDateTimeStrings(info->creationTime, creationDate, creationTime);
-
- // Set up modified date
- SetDateTimeStrings(info->changeTime, modificationDate, modificationTime);
-
- // Set up Send Updates
- SetLinkUpdateUpdateControls(dlg, info->autoUpdate);
-
- needsUpdate = (info->change == kODUnknownUpdate) || (info->change != link->GetUpdateID(ev));
-
- // Disable Update Now button if updates are automatic or destination is up to date.
- if ( info->autoUpdate || !needsUpdate )
- {
- SetControlActive(dlg, kLinkInfoUpdateBtn, kODFalse);
- }
-
- // Disable some items if changes are not allowed or draft is read only
- if ( !changesAllowed || DraftIsReadOnly(ev, link->GetStorageUnit(ev)) )
- {
- SetControlActive(dlg, kLinkInfoOnSaveRadioBtn, kODFalse);
- SetControlActive(dlg, kLinkInfoManualRadioBtn, kODFalse);
- SetControlActive(dlg, kLinkInfoBreakLinkBtn, kODFalse);
- SetControlActive(dlg, kLinkInfoUpdateBtn, kODFalse);
- }
-
- *boolResult = ShowLinkInfo(dlg, creationDate, creationTime, modificationDate,
- modificationTime, needsUpdate, infoResult);
-
- CATCH_ALL
- ODDisposeRoutineDescriptor(DrawBoxItemUPP);
- ODDisposeRoutineDescriptor(DrawKindNameUPP);
-
- refSaved = BeginUsingLibraryResources();
- ODDisposeDialog(dlg);
- EndUsingLibraryResources(refSaved);
-
- SetPort(savePort);
- // RERAISE;
- err = ErrorCode();
- ENDTRY
-
- ODDisposeRoutineDescriptor(DrawBoxItemUPP);
- ODDisposeRoutineDescriptor(DrawKindNameUPP);
-
- refSaved = BeginUsingLibraryResources();
- ODDisposeDialog(dlg);
- EndUsingLibraryResources(refSaved);
-
- SetPort(savePort);
-
- return err;
- }
-
-